﻿using System;
using System.Collections.Generic;
using System.Text;
using DevExpress.Xpo;
using System.Data.OleDb;
using System.Data;
using Component;

namespace Component
{
    public class WardsDB:Base
    {

        /// <summary>
        /// public static XPCollection<Ward> GetAll()
        /// </summary>
        /// <returns>XPCollection<Ward></returns>
        public static XPCollection<Ward> GetAll(bool admin)
        {
            XPCollection<Ward> _xpWard = new XPCollection<Ward>(KetNoiCSDL.session);
            _xpWard.Filter = FilterAll(admin);
            return _xpWard;
        }
        /// <summary>
        /// public static Ward GetObjectByid(int id)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static Ward GetObjectByid(int id, bool admin)
        {
            XPCollection<Ward> _xpWard = new XPCollection<Ward>(KetNoiCSDL.session);
            _xpWard.Filter = FilterById(id, true);
            if (_xpWard.Count > 0)
            {
                return _xpWard[0];
            }
            return null;
        }

        /// <summary>
        /// private static Category GetCategoryByidCategory(int idCategory,bool admin)
        /// </summary>
        /// <param name="idCategory"></param>
        /// <param name="admin"></param>
        /// <returns></returns>
        public static XPCollection<Ward> GetAllObjCode1Province(string code1)
        {
            XPCollection<Ward> _xpWard = new XPCollection<Ward>(KetNoiCSDL.session);
            _xpWard.Filter = DevExpress.Data.Filtering.CriteriaOperator.Parse(ColumWard._Code1 + ConstString._dauBang, code1);
            return _xpWard;
        }
    }
}
